import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    value:'',
    time:2000//ms
    // 倒计时失败了QAQ
  },
  getters: {
    valueLength(state){
      return state.value.length
    }
  },
  mutations: {
    getvalue:function(state,v){
      state.value = v
    },
    countdown:function(state){
      state.time -= 1
      if(state.time==0){
        state.time=0
      }
    }
  },
  actions: {
    a_getvalue(context,payload){
    setTimeout(()=>{
      context.commit('getvalue',payload)
      console.log(payload)
    },2000)
    }
  },
  modules: {
  }
})
